<template>
  <div>
    <div class="title">
      <span>{{merchantdetailarr[0].merchantName}}--营业统计详情</span>
      <div>
        <el-button type="primary" @click="merchantexcel()"><i class="el-icon-download"></i>导出</el-button>
        <el-button icon="el-icon-refresh" @click="merchantdetail"></el-button>
      </div>
    </div>
    <div class="container">
      <div class="tableBox">
        <el-table
          :data="merchantdetailarr"
          tooltip-effect="dark"
          style="width: 100%"
          @selection-change="handleSelectionChange"
          stripe
        >
          <el-table-column type="selection"></el-table-column>
          <el-table-column type="index" align="center" label="序号"></el-table-column>
          <el-table-column prop="tradeDate"  width="90" align="center" label="时间"></el-table-column>
          <!-- <el-table-column width="80" prop="aliTotalFee" label="交易金额"></el-table-column>
          <el-table-column width="65" prop="aliTotalFee" label="支付宝"></el-table-column>
          <el-table-column width="65" prop="aliTotalFee" label="微信"></el-table-column>
          <el-table-column width="65" prop="aliTotalFee" label="银行卡"></el-table-column>
          <el-table-column width="70" prop="aliTotalFee" label="结算金额"></el-table-column>
          <el-table-column width="65" prop="aliTotalFee" label="支付宝"></el-table-column>
          <el-table-column width="65" prop="aliTotalFee" label="微信"></el-table-column>
          <el-table-column width="65" prop="aliTotalFee" label="银行卡"></el-table-column>
          <el-table-column width="65" prop="aliTotalFee" label="手续费"></el-table-column>
          <el-table-column width="65" prop="aliTotalFee" label="支付宝"></el-table-column>
          <el-table-column width="65" prop="aliTotalFee" label="微信"></el-table-column>
          <el-table-column width="65" prop="aliTotalFee" label="银行卡"></el-table-column>
          <el-table-column width="65" prop="aliTotalFee" label="交易笔数"></el-table-column>
          <el-table-column width="65" prop="aliTotalFee" label="支付宝"></el-table-column>
          <el-table-column width="65" prop="aliTotalFee" label="微信"></el-table-column>
          <el-table-column width="65" prop="aliTotalFee" label="银行卡"></el-table-column> -->

          <el-table-column  prop="totalFee" align="center" label="交易总金额"></el-table-column>
          <el-table-column  prop="aliTotalFee" align="center" label="支付宝交易"></el-table-column>
          <el-table-column  prop="wxTotalFee" align="center" label="微信交易"></el-table-column>
          <el-table-column  prop="uniTotalFee" align="center" label="云闪付交易"></el-table-column>
          <el-table-column  prop="bankTotalFee" align="center" label="银行卡交易"></el-table-column>

          <el-table-column  prop="total" align="center" label="总笔数"></el-table-column>
          <el-table-column  prop="aliTotalCount" align="center" label="支付宝"></el-table-column>
          <el-table-column  prop="wxTotalCount" align="center" label="微信"></el-table-column>
          <el-table-column  prop="uniTotalCount" align="center" label="云闪付"></el-table-column>
          <el-table-column  prop="bankTotalCount" align="center" label="银行卡"></el-table-column>

          <el-table-column  prop="fee" align="center" label="总手续费"></el-table-column>
          <el-table-column  prop="aliFee" align="center" label="支付宝"></el-table-column>
          <el-table-column  prop="wxFee" align="center" label="微信"></el-table-column>
          <el-table-column  prop="uniFee" align="center" label="云闪付"></el-table-column>
          <el-table-column  prop="bankFee" align="center" label="银行卡"></el-table-column>
          <el-table-column prop="balance" align="center" label="结算总金额"></el-table-column>
        </el-table>
        <div class="pagination">
          <el-pagination
            background
            @current-change="handleCurrentChange"
            @size-change="sizechange"
            :current-page.sync="cur_page"
            :page-size="10"
            layout="total, sizes, prev, pager, next, jumper"
            :total="combined"
            v-loading="loading"
          ></el-pagination>
        </div>
      </div>
      <br>
      <br>
      <!-- 详细 -->
      <el-dialog v-dialogDrag title="商户交易明细" :visible.sync="visible" width="45%" :close-on-click-modal = "false">
        <div class="tableBox">
        <el-table tooltip-effect="dark" style="width: 100%">
             <el-table-column width="135" type="index" align="center" label=" "></el-table-column>
             <el-table-column width="135" type="index" align="center" label="交易金额"></el-table-column>
             <el-table-column width="135" type="index" align="center" label="手续费"></el-table-column>
             <el-table-column width="135" type="index" align="center" label="交易笔数"></el-table-column>
             <el-table-column width="135" type="index" align="center" label="结算金额"></el-table-column>
        </el-table>
        </div>
       
      </el-dialog>
    </div>
  </div>
</template>

<script>
import { addchannel, getSelect, channelupdate,merchantdetail,merchantdetailexcel } from "@/api/api";
export default {
  name: "baseform",
  data: function() {
    return {
      cur_page: 1,
      cur_size: 10,
      multipleSelection: [],
      merchantdetailarr:[{merchantName:''}],
      pageCount:"",
      keywords:"",
      combined: 10,
      visible: false,
      loading:true,
      storesinfo:{
        stardate:"",
        enddate:"",
        channelno:""
      },
      info:{},
      value9: [],
    };
  },
  created() {
    this.merchantdetail()
    // console.log(this.$route.query)
    
  },
  watch:{   //监听路由变化
   $route(item){
     if(item.fullPath.indexOf("businessstatisticsinfo") != -1 ){
        // console.log(this.id)
         merchantdetail({
          page: this.cur_page,
          size: this.cur_size,
          merchantId: this.$route.query.no,
          startDate:this.$route.query.date[0],
          endDate:this.$route.query.date[1],
          channelType: this.$route.query.channelType
        }).then(res => {
          console.log(res);
          if(res.code == 405){
            sessionStorage. removeItem('token')
            this.$router.push('/login');
          }else{
            this.merchantdetailarr = res.data.list
            this.cur_page = res.data.pageInfo.pageCurrent
            this.combined = res.data.pageInfo.recordCount
            this.loading = false
          }
        });
     }
    },
      
  },
  mounted() {
  
  },
  methods: {
    // 分页导航
    handleCurrentChange(val) {
      this.cur_page = val;
      this.merchantdetail()
       this.$nextTick(() => {
         document.querySelectorAll('.content')[0].scrollTop = '0'
      });
    },
     // 分页数量
    sizechange(val){
      this.cur_size = val
      this.merchantdetail()
       
       this.$nextTick(() => {
         document.querySelectorAll('.content')[0].scrollTop = '0'
      });
       
    },

    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    // 详情列表
    merchantdetail(){
       merchantdetail({
          page: this.cur_page,
          size: this.cur_size,
          merchantId: this.$route.query.no,
          startDate:this.$route.query.date[0],
          endDate:this.$route.query.date[1],
          channelType: this.$route.query.channelType
        }).then(res => {
          console.log(res);
          if(res.code == 405){
            sessionStorage. removeItem('token')
            this.$router.push('/login');
            
          }else{
            this.merchantdetailarr = res.data.list
            this.cur_page = res.data.pageInfo.pageCurrent
            this.combined = res.data.pageInfo.recordCount
            this.loading = false
          }
        });
    },
     // 导出
    merchantexcel(){
      this.exxxx = true;
      const loading = this.$loading({
      lock: true,
      text: 'Loading',
      spinner: 'el-icon-loading',
      background: 'rgba(0, 0, 0, 0.7)'
      });
        // console.log(sosolist)
        merchantdetailexcel({
          page: this.cur_page,
          size: this.cur_size,
          merchantId: this.$route.query.no,
          startDate:this.$route.query.date[0],
          endDate:this.$route.query.date[1],
          channelType: this.$route.query.channelType
        }).then(res => {
          if(res.code == 405){
            sessionStorage. removeItem('token')
            this.$router.push('/login');
             loading.close();
             this.exxxx = false;
          }else if(res.code == 200){
        let elink = document.createElement('a');
        elink.href = res.data;
        elink.click();
        loading.close();
        this.exxxx = false;
        }else{
          this.$message.error(res.message);
          loading.close();
          this.exxxx = false;
        }
      })
    },
  },
 
};
</script>
<style scoped lang="less">
.title {
  background: #fff;
  padding: 10px 10px;
  font-size: 18px;
  font-weight: 500;
  display: flex;
  justify-content: space-between;
}
.name {
  width: 25%;
}

.tableBox {
  margin-top: 20px;
  width: 100%;
}

.red {
  color: #f9607d;
}

.my-autocomplete {
  li {
    line-height: normal;
    padding: 7px;

    .name {
      text-overflow: ellipsis;
      overflow: hidden;
    }
    .addr {
      font-size: 12px;
      color: #b4b4b4;
    }

    .highlighted .addr {
      color: #ddd;
    }
  }
}
.el-table .warning-row {
    background: oldlace;
  }

</style>